<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
  <title>订单</title>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

  <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">

  <link rel="stylesheet" href="../lib/weui.min.css">
  <link rel="stylesheet" href="../css/jquery-weui.css">

</head>

<body ontouchstart>


<div class="weui-form-preview">
  <div class="weui-form-preview__hd">
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label">付款金额</label>
      <em class="weui-form-preview__value">¥${params.money}</em>
    </div>
  </div>
  <div class="weui-form-preview__bd">
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label">商品</label>
      <span class="weui-form-preview__value">测试商品</span>
    </div>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label">概要</label>
      <span class="weui-form-preview__value">支付测试</span>
    </div>

  </div>
  <div class="weui-form-preview__ft">
    <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" onclick="paynow()">现在支付</a>
  </div>
</div>

<script src="../lib/jquery-2.1.4.js"></script>
<script src="../js/jquery-weui.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" charset="utf-8"></script>
<script>
    function onBridgeReady(){
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId": "${params.appId}",     //公众号名称，由商户传入
                    "timeStamp":"${params.timeStamp}",         //时间戳，自1970年以来的秒数
                    "nonceStr": "${params.nonceStr}", //随机串
                    "package":"${params.packageStr}",
                    "signType":"${params.signType}",         //微信签名方式：
                    "paySign":"${params.paySign}" //微信签名
                },
                function (res) {
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        alert("支付成功");
                    } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                        alert("您已取消支付");
                    } else if (res.err_msg == "get_brand_wcpay_request:fail") {
                        alert("支付失败：" + JSON.stringify(res));
                    }
                }
            );
    }

    function paynow(){
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        }else{
            onBridgeReady();
        }
    }
</script>
</body>
</html>
